﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace RenderHeads.Media.AVProVideo.Demos
{
	// Token: 0x0200000A RID: 10
	public class Mapping3D : MonoBehaviour
	{
		// Token: 0x06000030 RID: 48 RVA: 0x000035A0 File Offset: 0x000017A0
		private void Update()
		{
			this._timer -= Time.deltaTime;
			if (this._timer <= 0f)
			{
				this._timer = 0.25f;
				this.SpawnCube();
				if (this._cubes.Count > 48)
				{
					this.RemoveCube();
				}
			}
		}

		// Token: 0x06000031 RID: 49 RVA: 0x000035F8 File Offset: 0x000017F8
		private void SpawnCube()
		{
			Quaternion rotation = Quaternion.Euler(UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f));
			float num = UnityEngine.Random.Range(0.1f, 0.6f);
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this._cubePrefab, base.transform.position, rotation);
			Transform component = gameObject.GetComponent<Transform>();
			component.localScale = new Vector3(num, num, num);
			this._cubes.Add(gameObject);
		}

		// Token: 0x06000032 RID: 50 RVA: 0x00003684 File Offset: 0x00001884
		private void RemoveCube()
		{
			GameObject obj = this._cubes[0];
			this._cubes.RemoveAt(0);
			UnityEngine.Object.Destroy(obj);
		}

		// Token: 0x04000027 RID: 39
		public GameObject _cubePrefab;

		// Token: 0x04000028 RID: 40
		private const int MaxCubes = 48;

		// Token: 0x04000029 RID: 41
		private const float SpawnTime = 0.25f;

		// Token: 0x0400002A RID: 42
		private float _timer = 0.25f;

		// Token: 0x0400002B RID: 43
		private List<GameObject> _cubes = new List<GameObject>(32);
	}
}
